<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../iconfont/iconfont.css">
    <link rel="stylesheet" href="../css/header.css">
</head>
<body>
    <!-- header -->
    <div class="header">
        <div class="headerbox">
             <ul>
                 <li>
                     <a href="">亲，请登录</a>
                 </li>
                 <li>
                     <a href="">免费注册</a>
                 </li>
                 <li>
                     <i class="iconfont">&#xe687;</i>
                     <span>搜索</span>
                 </li>
                 <li class="shoppingCar">
                     <i class="iconfont">&#x344b;</i>
                     <span>购物车</span>
                 </li>
                 <li>
                     <i class="iconfont">&#xe897;</i>
                     <span>我的订单</span>
                 </li>
                 <li>
                     <i class="iconfont">&#xe693;</i>
                     <span>专属导购</span>
                 </li>
                 <li class="wx"><span>关注ONLY微信</span></li>
                 <li>手机购物</li>
             </ul>
        </div>
     </div>
     <!-- nav -->
    <div class="nav">
        <div class="navbox">
            <a href="" class="imgx">
                <img src="../images/logo.jpg" alt="">
            </a>
            <ul>
                <li><a href="">首页</a></li>
                <li><a href="">冬季新品</a></li>
                <li><a href="">商场同款</a></li>
                <li><a href="">连衣裙</a></li>
                <li><a href="">牛仔裤</a></li>
                <li><a href="">外套</a></li>
                <li><a href="">针织衫</a></li>
                <li><a href="">IP合作款</a></li>
                <li><a href="">会员中心</a></li>
            </ul>
        </div>
    </div>
    <script src="../jquery/jquery.min.js"></script>
    <script src="../js/cookie.js"></script>
    <script>
        let cook = getCookie('username');
        if (cook) {
            $('.header .headerbox ul li:first-child a').text(cook);
            // console.log("****");
            $('.header .headerbox ul li:nth-child(2) a').text("退出");;
            $('.header .headerbox ul li:nth-child(2)').on('click','a',function(e){
                e.preventDefault();
                if($('.header .headerbox ul li:nth-child(2) a').text()=='退出'){
                delCookie('username');
                $('.header .headerbox ul li:nth-child(2) a').text("免费注册");
                $('.header .headerbox ul li:first-child a').text('亲，请登录');
                }
                else{
                location.href='html/register.html';
                }
            })
        }
    </script>
</body>
</html>